﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class HighScore : MonoBehaviour {
    public Text score;
    public Text coin;

	// Use this for initialization
	void Start () {
        Init();   	
	}
    void Init() {
        var easy = PlayerPrefs.GetInt(GamePreference.Easy);
        if(easy == 1) {
            var s = PlayerPrefs.GetInt(GamePreference.EasyHighScore);
            var c = PlayerPrefs.GetInt(GamePreference.EasyCoin);
            score.text = s.ToString();
            coin.text = c.ToString();
        }

        var medium  = PlayerPrefs.GetInt(GamePreference.Medium);
        if(medium == 1) {
            var s = PlayerPrefs.GetInt(GamePreference.MediumHighScore);
            var c = PlayerPrefs.GetInt(GamePreference.MediumCoin);
            score.text = s.ToString();
            coin.text = c.ToString();
        }

        var hard   = PlayerPrefs.GetInt(GamePreference.Hard);
        if(hard == 1) {
            var s = PlayerPrefs.GetInt(GamePreference.HardHighScore);
            var c = PlayerPrefs.GetInt(GamePreference.HardCoin);
            score.text = s.ToString();
            coin.text = c.ToString();
        }

        Debug.Log("easy, medium : "+easy+" m "+medium+" h "+hard);

        if(easy == 0 && medium == 0 && hard == 0) {
            score.text = "0";
            coin.text = "0";
        }
    }

	// Update is called once per frame
	void Update () {
	
	}
    public void Back() {
        UnityEngine.SceneManagement.SceneManager.LoadScene("MainMenu");
    }
}
